package com.huawei.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huawei.common.vo.PageInfoVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.huawei.domain.Emp;
import com.huawei.mapper.EmpMapper;
import com.huawei.service.EmpService;

import java.util.List;

/**
 * @Author LF
 * projectName:vue-cli
 * description:
 * time:2025-04-26 20:13
 */
@Service
public class EmpServiceImpl implements EmpService {

    @Resource
    private EmpMapper empMapper;

    @Override
    public int deleteByPrimaryKey(Integer empId) {
        return empMapper.deleteByPrimaryKey(empId);
    }

    @Override
    public int insert(Emp record) {
        return empMapper.insert(record);
    }

    @Override
    public int insertSelective(Emp record) {
        return empMapper.insertSelective(record);
    }

    @Override
    public Emp selectByPrimaryKey(Integer empId) {
        return empMapper.selectByPrimaryKey(empId);
    }

    @Override
    public int updateByPrimaryKeySelective(Emp record) {
        return empMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Emp record) {
        return empMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfoVo queryEmpByPage(PageInfoVo pageInfoVo) {
        PageHelper.startPage(pageInfoVo.getPageNum(), pageInfoVo.getPageSize());
        List<Emp> empList = empMapper.queryAllEmp(pageInfoVo.getParams());
        PageInfo<Emp> pages = new PageInfo<>(empList);
        pageInfoVo.setTotal(pages.getTotal());
        pageInfoVo.setPages(pages.getPages());
        pageInfoVo.setData(pages.getList());
        return pageInfoVo;
    }

}
